const api = require('../../../api/mop_api');
import { toast, log, err } from '../../../utils/wxapi';
Page({
  data: {
    id: '',
    item: {},
    memberId: '',
    show: false,
    devices: [],
    connected: false,
    chs: [],
    deskNo: '',
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.setData({ id: options.id, memberId: JSON.parse(options.memberId), deskNo: options.deskNo });
  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    this.getord();
  },
  async getord() {
    try {
      const { id } = this.data;
      const res = await api.orderget({ id });
      if (res.respCode === 200) {
        const item = JSON.parse(res.source);
        log(item);
        this.setData({ item });
      } else {
        toast(res.msg);
      }
    } catch (error) {
      err(error);
      throw error;
    }
  },
  print() {
    this.setData({ show: true });
  },
});
